import request from "@/utils/request";
import { AxiosPromise } from "axios";
import {
  config,
  configGroup,
  configQuery
} from "./types";

export function fetchList(queryParams: configQuery) {
  return request({
    url: '/admin/config/getAll',
    method: 'get',
    params: queryParams
  })
}

export function getConfigLst(queryParams: configQuery): AxiosPromise<PageResult<config[]>> {
  return request({
    url: '/admin/config/index',
    method: 'get',
    params: queryParams
  })
}

export function getGroupLst() {
  return request({
    url: '/admin/configGroup/getAll',
    method: 'get'
  })
}


export function save(data: any) {
  return request({
    url: '/admin/config/save',
    method: 'post',
    data
  })
}

export function createConfig(data: any) {
  return request({
    url: '/admin/config/add',
    method: 'post',
    data
  })
}

export function createConfigGroup(data: any) {
  return request({
    url: '/admin/configGroup/add',
    method: 'post',
    data
  })
}

export function editConfig(data: any) {
  return request({
    url: '/admin/config/edit',
    method: 'post',
    data
  })
}

export function editConfigGroup(data: any) {
  return request({
    url: '/admin/configGroup/edit',
    method: 'post',
    data
  })
}

export function configForms(ids: number) {
  return request({
    url: '/admin/config/edit',
    method: 'get',
    params: {
      ids: ids
    }
  })
}

export function configGroupForms(ids: number) {
  return request({
    url: '/admin/configGroup/edit',
    method: 'get',
    params: {
      ids: ids
    }
  })
}

export function delConfig(data:any) {
  return request({
    url: '/admin/config/del',
    method: 'delete',
    data
  })
}

export function delConfigGroup(data:any) {
  return request({
    url: '/admin/configGroup/del',
    method: 'delete',
    data
  })
}

